home *** CD-ROM | disk | FTP | other *** search
- SETDIR - Use to restore the current directory
-
- Requires DOS 2.0 or above and 2048 bytes of disk and memory space (not resident
- when not in use).
-
-
- Copyright 1986, Arnold B. Krueger GPW MI 48236
- (ARNY KRUEGER @EXEC-PC 414-964-5160)
- Permission for free use and distribution by
- interested parties, not for profit, granted.
-
- SETDIR sets the environment string 'CURDIR' with the current directory. Once
- this has been done it is very simple to restore the current directory after it
- has been changed by some other program. To restore the current directory, once
- saved by SETDIR, simply issue the following command:
-
- CD %CURDIR%
-
- This technique has distinct advantages over other techniques that create files
- (CD >CURDIR.FIL) or modify the interupt vector (PUSHDIR/POPDIR from PC magazine
- and/or PC OUTLINE). It is much faster, creates no files, cannot be impacted by
- programs that modify the interrupt vector, and requires only one very small
- (<512 byte) program. Paraphrasing Uncle Lee Iacocca: "If there is a better
- program, use it!"
-
- If you desire setting an environment variable other than CURDIR, use the
- following:
-
- SETDIR name
-
- The environment variable "name" will be set to the current directory.
-
- Example:
-
- In my batch file, I want to change directory to directory \$TEMP,
- edit a file named FUN.FIL, and then return to the current directory:
-
- Echo off
- b:setdir oldir
- cd \$temp
- ed fun.fil
- cd %oldir%
-
- This file is included as: TEST.BAT, and assumes that: SETDIR is on the B disk,
- and a subdirectory named \$temp exists on the curent disk.
-
- Note that SETDIR DOES NOT CHANGE THE CURRENT DIRECTORY. You must do this via
- the CD command. All SETDIR does is put the name of the current directory where
- it is accessible to the batch language.
-
-
- Since the PATH is in the environment string, a similar procedure can be used to
- save it:
- SET SAVPATH=%PATH%
- .
- .
- .
-
- PATH %SAVPATH%
-
-
-
- ERRORLEVEL setting by this program:
-
- Note that due to limitations in DOS, the errorlevel can be 0 even if
- SETDIR fails due to lack of environment space. Errorlevels 1 and 2
- are for SETDIR detected errors. Errorlevel=1 means the DOS release is not at
- least 2. Errorlevel=2 means that the directory string was too long to return.
-
-
-